#include <pthread.h>
#include <stdio.h>

void *threadSafe(void *args){
    int *threadID = (int *)args;
    printf("Hello form thread:%d\n",*threadID);

}

int main(){
    int i,j;

    int NUM_THREADS = 10;
    pthread_t threads[NUM_THREADS];
    int thread_args[NUM_THREADS];

    printf("Not in thread!\n");
    //创建10个线程
    for (i = 0;i<NUM_THREADS;i++){
        thread_args[i] = i;
        pthread_create(&threads[i],NULL,threadSafe,(void *)&thread_args[i]);

    }
    //等待10个线程
    for (j = 0;j<NUM_THREADS;j++){
        pthread_join(threads[j],NULL);

    }
    printf("After thread!\n");
    pthread_exit(NULL);
    return 0;
}